#ifndef _GAME_H_
#define _GAME_H_

#include"Common.h"
#include"Camera.h"
#include"ResourceManger.h"
#include"VertexArray.h"
#include"ChunkRender.h"
#include"Chunk.h"
#include"Block.h"
#include"SkyBox.h"
#include"SpriteRender.h"

#include<memory>
#include<string>
#include<vector>
#include<map>
#include<list>

namespace Craft{


/*
	@brief
*/
class Game
{
public:
	Game();
	Game(const Game& game) = delete;
	Game& operator=(const Game& game) = delete;

	~Game();

	void init();

	void update(double deltaTime);
	void draw();
	void stop();

	void notify_input( double deltaTime);
	void notify_mouse(double xpos, double ypos);

	void init_data();

	// it will put in world class
	std::vector<AABB> get_hitBoxes(const AABB& box);

private:

	std::unique_ptr<Camera> m_Camera;
	SpriteRender *m_sprite;
	SkyBox sky;

	// it will put in world class
	void get_current_block();
	void try_build_block();
	void try_destory_block();
	void render_update(const glm::vec3& position);
	void load_chunks();
	void save_chunks();

	const GLfloat render_range = 30.0f;

	// manging chunks simply
	std::list<Chunk*> m_chunks;
	GLuint get_chunkId_byPos(const glm::vec3& pos);

	std::map<Chunk*,ChunkRender> rends;
	DepdentBlockRender blockRend;

	Block currBlock;
	Block buildBlock;
	HitInfo hitInfo;


	int temp_indices;
};

}

#endif